package com.work.keep.activity;

import android.app.Activity;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * Created by dllo on 16/1/7.
 * 控制activity的类
 */
public class ActivityControl {

    private static final Map<String, Activity> activityMap = new HashMap<>();

    //添加activity
    public static void addActivity(String key, Activity aty) {
        activityMap.put(key, aty);
    }

    //判断删除activity的正确与否
    public static boolean removeActivity(String key) {
        Activity activity = activityMap.remove(key);
        if (activity != null) {
            return true;
        }
        return false;
    }

    //finish全部activity
    public static void finishAll() {
        Set<String> activities = activityMap.keySet();
        for (String key : activities) {
            activityMap.get(key).finish();
        }
    }
}
